﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2021-2025 LiLong                                              **
**  This file is part of CommonUnits.                                           **
**                                                                              **
**  CommonUnits is free software: you can redistribute it and/or modify         **
**  it under the terms of the GNU Lesser General Public License as published by **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  CommonUnits is distributed in the hope that it will be useful,              **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU Lesser General Public License for more details.                         **
**                                                                              **
**  You should have received a copy of the GNU Lesser General Public License    **
**  along with CommonUnits.  If not, see <https://www.gnu.org/licenses/>.       **
**********************************************************************************/
#pragma once

#include "../CommonUnits.h"
#include "../UnitLists.h"

namespace CU
{
inline namespace Resistance
{
namespace Units
{
using Ohm  = StandardUnit<"Ω">;
using mOhm = DeriveUnit<Ohm, "mΩ", std::milli>;
using uOhm = DeriveUnit<Ohm, "μΩ", std::micro>;
using nOhm = DeriveUnit<Ohm, "nΩ", std::nano>;
using pOhm = DeriveUnit<Ohm, "pΩ", std::pico>;
using fOhm = DeriveUnit<Ohm, "fΩ", std::femto>;
using aOhm = DeriveUnit<Ohm, "aΩ", std::atto>;
using KOhm = DeriveUnit<Ohm, "kΩ", std::kilo>;
using MOhm = DeriveUnit<Ohm, "MΩ", std::mega>;
using GOhm = DeriveUnit<Ohm, "GΩ", std::giga>;
using TOhm = DeriveUnit<Ohm, "TΩ", std::tera>;
using POhm = DeriveUnit<Ohm, "PΩ", std::peta>;
using EOhm = DeriveUnit<Ohm, "EΩ", std::exa>;

using ResistanceList = UnitLists<aOhm, fOhm, pOhm, nOhm, uOhm, mOhm, Ohm, KOhm, MOhm, GOhm, TOhm, POhm, EOhm>;
} // namespace Units
using Ohm      = CommonUnits<double, Units::Ohm>;
using Milliohm = CommonUnits<double, Units::mOhm>;
using Microohm = CommonUnits<double, Units::uOhm>;
using Nanoohm  = CommonUnits<double, Units::nOhm>;
using Picoohm  = CommonUnits<double, Units::pOhm>;
using Femtoohm = CommonUnits<double, Units::fOhm>;
using Attoohm  = CommonUnits<double, Units::aOhm>;
using Kiloohm  = CommonUnits<double, Units::KOhm>;
using Megaohm  = CommonUnits<double, Units::MOhm>;
using Gigaohm  = CommonUnits<double, Units::GOhm>;
using Teraohm  = CommonUnits<double, Units::TOhm>;
using Petaohm  = CommonUnits<double, Units::POhm>;
using Exaohm   = CommonUnits<double, Units::EOhm>;

namespace Literals
{
constexpr auto operator""_Ω(long double val) { return Ohm(val); }
constexpr auto operator""_mΩ(long double val) { return Milliohm(val); }
constexpr auto operator""_uΩ(long double val) { return Microohm(val); }
constexpr auto operator""_nΩ(long double val) { return Nanoohm(val); }
constexpr auto operator""_pΩ(long double val) { return Picoohm(val); }
constexpr auto operator""_fΩ(long double val) { return Femtoohm(val); }
constexpr auto operator""_aΩ(long double val) { return Attoohm(val); }
constexpr auto operator""_kΩ(long double val) { return Kiloohm(val); }
constexpr auto operator""_MΩ(long double val) { return Megaohm(val); }
constexpr auto operator""_GΩ(long double val) { return Gigaohm(val); }
constexpr auto operator""_TΩ(long double val) { return Teraohm(val); }
constexpr auto operator""_PΩ(long double val) { return Petaohm(val); }
constexpr auto operator""_EΩ(long double val) { return Exaohm(val); }
} // namespace Literals

template<typename Unit>
inline auto toUnit(double value, const std::string& dest) -> Unit
{
    return toUnitHelper<Unit, Units::ResistanceList>(value, dest);
}
} // namespace Resistance
} // namespace CU
